"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var vue_1 = require("vue");
var vue_router_1 = require("vue-router");
var spaceController_1 = require("@/api/spaceController");
var pictureController_1 = require("@/api/pictureController");
var ant_design_vue_1 = require("ant-design-vue");
var PictureList_vue_1 = __importDefault(require("@/components/PictureList.vue"));
var utils_1 = require("../utils");
var PictureSearchForm_vue_1 = __importDefault(require("@/components/PictureSearchForm.vue"));
var vue3_colorpicker_1 = require("vue3-colorpicker");
require("vue3-colorpicker/style.css");
var space_1 = require("../constant/space");
var props = defineProps();
var space = (0, vue_1.ref)({});
// 数据
var dataList = (0, vue_1.ref)([]);
var total = (0, vue_1.ref)(0);
var loading = (0, vue_1.ref)(true);
var route = (0, vue_router_1.useRoute)();
// 通用权限检查函数
function createPermissionChecker(permission) {
    return (0, vue_1.computed)(function () {
        var _a;
        return ((_a = space.value.permissionList) !== null && _a !== void 0 ? _a : []).includes(permission);
    });
}
// 定义权限检查
var canManageSpaceUser = createPermissionChecker(space_1.SPACE_PERMISSION_ENUM.SPACE_USER_MANAGE);
var canUploadPicture = createPermissionChecker(space_1.SPACE_PERMISSION_ENUM.PICTURE_UPLOAD);
var canEditPicture = createPermissionChecker(space_1.SPACE_PERMISSION_ENUM.PICTURE_EDIT);
var canDeletePicture = createPermissionChecker(space_1.SPACE_PERMISSION_ENUM.PICTURE_DELETE);
// 获取空间详情
var fetchSpaceDetail = function () { return __awaiter(void 0, void 0, void 0, function () {
    var res, e_1;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                _a.trys.push([0, 2, , 3]);
                return [4 /*yield*/, (0, spaceController_1.getSpaceVoByIdUsingGet)({
                        id: props.id,
                    })];
            case 1:
                res = _a.sent();
                if (res.data.code === 0 && res.data.data) {
                    space.value = res.data.data;
                }
                else {
                    ant_design_vue_1.message.error('获取空间详情失败，' + res.data.message);
                }
                return [3 /*break*/, 3];
            case 2:
                e_1 = _a.sent();
                ant_design_vue_1.message.error('获取空间详情失败：' + e_1.message);
                return [3 /*break*/, 3];
            case 3: return [2 /*return*/];
        }
    });
}); };
(0, vue_1.onMounted)(function () {
    fetchSpaceDetail();
});
// 搜索条件
var searchParams = (0, vue_1.ref)({
    current: 1,
    pageSize: 12,
    sortField: 'createTime',
    sortOrder: 'descend',
});
// 分页参数
var onPageChange = function (page, pageSize) {
    searchParams.value.current = page;
    searchParams.value.pageSize = pageSize;
    fetchData();
};
// 搜索
var onSearch = function (newSearchParams) {
    searchParams.value = __assign(__assign(__assign({}, searchParams.value), newSearchParams), { current: 1 });
    fetchData();
};
// 获取数据
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
    var params, res;
    var _a, _b;
    return __generator(this, function (_c) {
        switch (_c.label) {
            case 0:
                loading.value = true;
                params = __assign({ spaceId: props.id }, searchParams.value);
                return [4 /*yield*/, (0, pictureController_1.listPictureVoByPageUsingPost)(params)];
            case 1:
                res = _c.sent();
                if (res.data.data) {
                    dataList.value = (_a = res.data.data.records) !== null && _a !== void 0 ? _a : [];
                    total.value = (_b = res.data.data.total) !== null && _b !== void 0 ? _b : 0;
                }
                else {
                    ant_design_vue_1.message.error('获取数据失败，' + res.data.message);
                }
                loading.value = false;
                return [2 /*return*/];
        }
    });
}); };
// 页面加载时请求一次
(0, vue_1.onMounted)(function () {
    fetchData();
});
var onColorChange = function (color) { return __awaiter(void 0, void 0, void 0, function () {
    var res, data;
    var _a;
    return __generator(this, function (_b) {
        switch (_b.label) {
            case 0: return [4 /*yield*/, (0, pictureController_1.searchPictureByColorUsingPost)({
                    picColor: color,
                    spaceId: props.id,
                })];
            case 1:
                res = _b.sent();
                if (res.data.code === 0 && res.data.data) {
                    data = (_a = res.data.data) !== null && _a !== void 0 ? _a : [];
                    dataList.value = data;
                    total.value = data.length;
                }
                else {
                    ant_design_vue_1.message.error('获取数据失败，' + res.data.message);
                }
                return [2 /*return*/];
        }
    });
}); };
// 空间 id 改变时，必须重新获取数据
(0, vue_1.watch)(function () { return props.id; }, function (newSpaceId) {
    fetchSpaceDetail();
    fetchData();
}); /* PartiallyEnd: #3632/scriptSetup.vue */
function __VLS_template() {
    var __VLS_ctx = {};
    var __VLS_components;
    var __VLS_directives;
    // CSS variable injection 
    // CSS variable injection end 
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
        id: ("spaceDetailPage"),
    });
    var __VLS_0 = {}.AFlex;
    /** @type { [typeof __VLS_components.AFlex, typeof __VLS_components.aFlex, typeof __VLS_components.AFlex, typeof __VLS_components.aFlex, ] } */ ;
    // @ts-ignore
    var __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({
        justify: ("space-between"),
    }));
    var __VLS_2 = __VLS_1.apply(void 0, __spreadArray([{
            justify: ("space-between"),
        }], __VLS_functionalComponentArgsRest(__VLS_1), false));
    __VLS_elementAsFunction(__VLS_intrinsicElements.h2, __VLS_intrinsicElements.h2)({});
    (__VLS_ctx.space.spaceName);
    (__VLS_ctx.SPACE_TYPE_MAP[__VLS_ctx.space.spaceType]);
    var __VLS_6 = {}.ASpace;
    /** @type { [typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, ] } */ ;
    // @ts-ignore
    var __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({
        size: ("middle"),
    }));
    var __VLS_8 = __VLS_7.apply(void 0, __spreadArray([{
            size: ("middle"),
        }], __VLS_functionalComponentArgsRest(__VLS_7), false));
    if (__VLS_ctx.canUploadPicture) {
        var __VLS_12 = {}.AButton;
        /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
        // @ts-ignore
        var __VLS_13 = __VLS_asFunctionalComponent(__VLS_12, new __VLS_12({
            type: ("primary"),
            href: (("/add_picture?spaceId=".concat(__VLS_ctx.id))),
            target: ("_blank"),
        }));
        var __VLS_14 = __VLS_13.apply(void 0, __spreadArray([{
                type: ("primary"),
                href: (("/add_picture?spaceId=".concat(__VLS_ctx.id))),
                target: ("_blank"),
            }], __VLS_functionalComponentArgsRest(__VLS_13), false));
        __VLS_17.slots.default;
        var __VLS_17;
    }
    var __VLS_18 = {}.ATooltip;
    /** @type { [typeof __VLS_components.ATooltip, typeof __VLS_components.aTooltip, typeof __VLS_components.ATooltip, typeof __VLS_components.aTooltip, ] } */ ;
    // @ts-ignore
    var __VLS_19 = __VLS_asFunctionalComponent(__VLS_18, new __VLS_18({
        title: (("\u5360\u7528\u7A7A\u95F4 ".concat(__VLS_ctx.formatSize(__VLS_ctx.space.totalSize), " / ").concat(__VLS_ctx.formatSize(__VLS_ctx.space.maxSize)))),
    }));
    var __VLS_20 = __VLS_19.apply(void 0, __spreadArray([{
            title: (("\u5360\u7528\u7A7A\u95F4 ".concat(__VLS_ctx.formatSize(__VLS_ctx.space.totalSize), " / ").concat(__VLS_ctx.formatSize(__VLS_ctx.space.maxSize)))),
        }], __VLS_functionalComponentArgsRest(__VLS_19), false));
    var __VLS_24 = {}.AProgress;
    /** @type { [typeof __VLS_components.AProgress, typeof __VLS_components.aProgress, ] } */ ;
    // @ts-ignore
    var __VLS_25 = __VLS_asFunctionalComponent(__VLS_24, new __VLS_24({
        type: ("circle"),
        percent: ((((__VLS_ctx.space.totalSize * 100) / __VLS_ctx.space.maxSize).toFixed(1))),
        size: ((42)),
    }));
    var __VLS_26 = __VLS_25.apply(void 0, __spreadArray([{
            type: ("circle"),
            percent: ((((__VLS_ctx.space.totalSize * 100) / __VLS_ctx.space.maxSize).toFixed(1))),
            size: ((42)),
        }], __VLS_functionalComponentArgsRest(__VLS_25), false));
    __VLS_23.slots.default;
    var __VLS_23;
    if (__VLS_ctx.canEditPicture) {
        var __VLS_30 = {}.AButton;
        /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
        // @ts-ignore
        var __VLS_31 = __VLS_asFunctionalComponent(__VLS_30, new __VLS_30({
            type: ("primary"),
            ghost: (true),
            icon: ((__VLS_ctx.h(__VLS_ctx.BarChartOutlined))),
            href: (("/space_analyze?spaceId=".concat(__VLS_ctx.id))),
            target: ("_blank"),
        }));
        var __VLS_32 = __VLS_31.apply(void 0, __spreadArray([{
                type: ("primary"),
                ghost: (true),
                icon: ((__VLS_ctx.h(__VLS_ctx.BarChartOutlined))),
                href: (("/space_analyze?spaceId=".concat(__VLS_ctx.id))),
                target: ("_blank"),
            }], __VLS_functionalComponentArgsRest(__VLS_31), false));
        __VLS_35.slots.default;
        var __VLS_35;
    }
    if (__VLS_ctx.canManageSpaceUser) {
        var __VLS_36 = {}.AButton;
        /** @type { [typeof __VLS_components.AButton, typeof __VLS_components.aButton, typeof __VLS_components.AButton, typeof __VLS_components.aButton, ] } */ ;
        // @ts-ignore
        var __VLS_37 = __VLS_asFunctionalComponent(__VLS_36, new __VLS_36({
            type: ("primary"),
            ghost: (true),
            icon: ((__VLS_ctx.h(__VLS_ctx.TeamOutlined))),
            href: (("/spaceUserManage/".concat(__VLS_ctx.id))),
            target: ("_blank"),
        }));
        var __VLS_38 = __VLS_37.apply(void 0, __spreadArray([{
                type: ("primary"),
                ghost: (true),
                icon: ((__VLS_ctx.h(__VLS_ctx.TeamOutlined))),
                href: (("/spaceUserManage/".concat(__VLS_ctx.id))),
                target: ("_blank"),
            }], __VLS_functionalComponentArgsRest(__VLS_37), false));
        __VLS_41.slots.default;
        var __VLS_41;
    }
    __VLS_11.slots.default;
    var __VLS_11;
    __VLS_5.slots.default;
    var __VLS_5;
    // @ts-ignore
    /** @type { [typeof PictureSearchForm, ] } */ ;
    // @ts-ignore
    var __VLS_42 = __VLS_asFunctionalComponent(PictureSearchForm_vue_1.default, new PictureSearchForm_vue_1.default({
        onSearch: ((__VLS_ctx.onSearch)),
    }));
    var __VLS_43 = __VLS_42.apply(void 0, __spreadArray([{
            onSearch: ((__VLS_ctx.onSearch)),
        }], __VLS_functionalComponentArgsRest(__VLS_42), false));
    var __VLS_47 = {}.AFormItem;
    /** @type { [typeof __VLS_components.AFormItem, typeof __VLS_components.aFormItem, typeof __VLS_components.AFormItem, typeof __VLS_components.aFormItem, ] } */ ;
    // @ts-ignore
    var __VLS_48 = __VLS_asFunctionalComponent(__VLS_47, new __VLS_47(__assign({ label: ("按颜色搜索") }, { style: ({}) })));
    var __VLS_49 = __VLS_48.apply(void 0, __spreadArray([__assign({ label: ("按颜色搜索") }, { style: ({}) })], __VLS_functionalComponentArgsRest(__VLS_48), false));
    var __VLS_53 = {}.ColorPicker;
    /** @type { [typeof __VLS_components.ColorPicker, typeof __VLS_components.colorPicker, ] } */ ;
    // @ts-ignore
    var __VLS_54 = __VLS_asFunctionalComponent(__VLS_53, new __VLS_53(__assign({ 'onPureColorChange': {} }, { format: ("hex") })));
    var __VLS_55 = __VLS_54.apply(void 0, __spreadArray([__assign({ 'onPureColorChange': {} }, { format: ("hex") })], __VLS_functionalComponentArgsRest(__VLS_54), false));
    var __VLS_59;
    var __VLS_60 = {
        onPureColorChange: (__VLS_ctx.onColorChange)
    };
    var __VLS_56;
    var __VLS_57;
    var __VLS_58;
    __VLS_52.slots.default;
    var __VLS_52;
    // @ts-ignore
    /** @type { [typeof PictureList, ] } */ ;
    // @ts-ignore
    var __VLS_61 = __VLS_asFunctionalComponent(PictureList_vue_1.default, new PictureList_vue_1.default({
        dataList: ((__VLS_ctx.dataList)),
        loading: ((__VLS_ctx.loading)),
        showOp: ((true)),
        canEdit: ((__VLS_ctx.canEditPicture)),
        canDelete: ((__VLS_ctx.canDeletePicture)),
        onReload: ((__VLS_ctx.fetchData)),
    }));
    var __VLS_62 = __VLS_61.apply(void 0, __spreadArray([{
            dataList: ((__VLS_ctx.dataList)),
            loading: ((__VLS_ctx.loading)),
            showOp: ((true)),
            canEdit: ((__VLS_ctx.canEditPicture)),
            canDelete: ((__VLS_ctx.canDeletePicture)),
            onReload: ((__VLS_ctx.fetchData)),
        }], __VLS_functionalComponentArgsRest(__VLS_61), false));
    var __VLS_66 = {}.APagination;
    /** @type { [typeof __VLS_components.APagination, typeof __VLS_components.aPagination, ] } */ ;
    // @ts-ignore
    var __VLS_67 = __VLS_asFunctionalComponent(__VLS_66, new __VLS_66(__assign(__assign({ 'onChange': {} }, { style: ({}) }), { current: ((__VLS_ctx.searchParams.current)), pageSize: ((__VLS_ctx.searchParams.pageSize)), total: ((__VLS_ctx.total)), showTotal: ((function () { return "\u56FE\u7247\u603B\u6570 ".concat(__VLS_ctx.total, " / ").concat(__VLS_ctx.space.maxCount); })) })));
    var __VLS_68 = __VLS_67.apply(void 0, __spreadArray([__assign(__assign({ 'onChange': {} }, { style: ({}) }), { current: ((__VLS_ctx.searchParams.current)), pageSize: ((__VLS_ctx.searchParams.pageSize)), total: ((__VLS_ctx.total)), showTotal: ((function () { return "\u56FE\u7247\u603B\u6570 ".concat(__VLS_ctx.total, " / ").concat(__VLS_ctx.space.maxCount); })) })], __VLS_functionalComponentArgsRest(__VLS_67), false));
    var __VLS_72;
    var __VLS_73 = {
        onChange: (__VLS_ctx.onPageChange)
    };
    var __VLS_69;
    var __VLS_70;
    var __VLS_71;
    var __VLS_slots;
    var $slots;
    var __VLS_inheritedAttrs;
    var $attrs;
    var __VLS_refs = {};
    var $refs;
    var $el;
    return {
        attrs: {},
        slots: __VLS_slots,
        refs: $refs,
        rootEl: $el,
    };
}
;
var __VLS_self = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {
            h: vue_1.h,
            PictureList: PictureList_vue_1.default,
            formatSize: utils_1.formatSize,
            PictureSearchForm: PictureSearchForm_vue_1.default,
            ColorPicker: vue3_colorpicker_1.ColorPicker,
            SPACE_TYPE_MAP: space_1.SPACE_TYPE_MAP,
            space: space,
            dataList: dataList,
            total: total,
            loading: loading,
            canManageSpaceUser: canManageSpaceUser,
            canUploadPicture: canUploadPicture,
            canEditPicture: canEditPicture,
            canDeletePicture: canDeletePicture,
            searchParams: searchParams,
            onPageChange: onPageChange,
            onSearch: onSearch,
            fetchData: fetchData,
            onColorChange: onColorChange,
        };
    },
    __typeProps: {},
});
exports.default = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {};
    },
    __typeProps: {},
    __typeEl: {},
});
; /* PartiallyEnd: #4569/main.vue */
